﻿using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;

namespace Ordinaire.Business.FoodBeverage.Sales.Data
{
    [Table(Name = "Good")]
    public class GoodData : Ordinaire.Business.Data.GoodData<int, string>
    {
        #region Constructor

        /// <summary>
        /// Returns new instance of SaleItem.
        /// </summary>
        /// <remarks>used by DataContext to create new parameterless instance</remarks>
        public GoodData() : base() { }

        /// <summary>
        /// Returns a new instance of Ordinaire.Business.FoodBeverage.Sales.Data with the specified SaleItem.
        /// </summary>
        /// <param name="item">instance of Ordinaire.Business.SaleItem</param>
        //public GoodData(Ordinaire.Business.Good<int> item) : base(item)
        //{
        //    if (item is Food)
        //    {
        //        this.description = ((Food)item).Description;
        //    }
        //}

        #endregion

        #region Variables

        /// <summary>
        /// Item description esp. Food.
        /// </summary>
        private string description;

        #endregion

        #region Property methods

        /// <summary>
        /// Gets or sets sale item type.
        /// </summary>
        [Column]
        public override string Type
        {
            get { return base.Type; }
            set { base.Type = value.ToLower(); }
        }

        /// <summary>
        /// Gets or set item description.
        /// </summary>
        [Column]
        public string Description
        {
            get { return this.description; }
            set { this.description = value; }
        }

        #region Ordinaire.Business.Data.SaleItem

        [Column]
        public override decimal Discount
        {
            get { return base.Discount; }
            set { base.Discount = value; }
        }

        [Column]
        public override decimal Price
        {
            get { return base.Price; }
            set { base.Price = value; }
        }

        [Column]
        public override int Qty
        {
            get { return base.Qty; }
            set { base.Qty = value; }
        }

        [Column]
        public override decimal Tax
        {
            get { return base.Tax; }
            set { base.Tax = value; }
        }

        [Column]
        public override string Unit
        {
            get { return base.Unit; }
            set { base.Unit = value; }
        }

        #endregion

        #region Ordinaire.Data

        /// <summary>
        /// Get or set unique id
        /// </summary>
        [Column(IsPrimaryKey=true, IsDbGenerated = true, UpdateCheck=UpdateCheck.Never)]
        public override int Id
        {
            get { return base.Id; }
            set { base.Id = value; }
        }

        /// <summary>
        /// Get or set vocabulary
        /// </summary>
        [Column(UpdateCheck=UpdateCheck.Never)]
        public override string Name
        {
            get { return base.Name; }
            set { base.Name = value; }
        }

        /// <summary>
        /// Get or set creator
        /// </summary>
        [Column(UpdateCheck=UpdateCheck.Never)]
        public override string CreatedBy
        {
            get { return base.CreatedBy; }
            set { base.CreatedBy = value.TrimOrEmpty(); }
        }

        /// <summary>
        /// Get or set creation date
        /// </summary>
        [Column(UpdateCheck=UpdateCheck.Never)]
        public override DateTime? CreatedOn
        {
            get { return base.CreatedOn; }
            set { base.CreatedOn = value; }
        }

        /// <summary>
        /// Get or set updator
        /// </summary>
        [Column(UpdateCheck=UpdateCheck.Never)]
        public override string UpdatedBy
        {
            get { return base.UpdatedBy; }
            set { base.UpdatedBy = value.TrimOrEmpty(); }
        }

        /// <summary>
        /// Get or set update date
        /// </summary>
        [Column(UpdateCheck=UpdateCheck.Never)]
        public override DateTime? UpdatedOn
        {
            get { return base.UpdatedOn; }
            set { base.UpdatedOn = value; }
        }

        #endregion

        #endregion
    }
}
